{__NOLAYOUT__}
<div class="show">
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">结算方式</label>
                <input type="radio" name="testradio" value="1" title="按公里结算" checked>
                <input type="radio" name="testradio" value="2" title="按时间结算">
            </div>
        </div>
        <input type="hidden" name="id" class="id" value="{$id}">
        <input type="hidden" name="start_date" class="start_date" value="{$start_date}">
        <input type="hidden" name="end_date" class="end_date" value="{$end_date}">
        <input type="hidden" name="travel_time" class="travel_time" value="{$travel_time}">
        <input type="hidden" name="mileage" class="mileage" value="{$mileage}">
        <input type="hidden" name="type" class="type" value="{$type}">
    </form>

    <div class="layui-form-item " style="text-align: center">

        <button class="layui-btn sub">提交</button>
    </div>
</div>
<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;
        form.render(); //更新全部
    });
</script>

<script>
    $(".sub").click(function () {
        var val = $('input[name="testradio"]:checked').val();
        var id = $('.id').val();
        var start_date = $('.start_date').val();
        var end_date = $('.end_date').val();
        var mileage = $('.mileage').val();
        var travel_time = $('.travel_time').val();
        var type = $('.type').val();
        $.ajax({
            type: 'post',
            url: "{:url('Payment/payOff')}",
            data: {
                val: val,
                type: type,
                id: id,
                start_date: start_date,
                end_date: end_date,
                mileage: mileage,
                travel_time: travel_time
            },
            dataType: 'json',
            success: function (res) {
                var html = '';
                var tips = '';

                if (res.code == 200) {
                    if (type == 3) {
                        tips = "该车辆薪酬为";
                    } else {
                        tips = "该驾驶员薪酬为";
                    }
                    if (res.data.start_date && res.data.end_date) {
                        html += '<div style="text-align: center;height: 100px;margin-top: 20px">' + res.data.start_date + '至' + res.data.end_date + '' + tips + '' + res.data.total_price + '</div>';
                    } else {
                        html += '<div style="text-align: center;height: 100px;margin-top: 20px">' + tips + ' '+ res.data.total_price + '</div>';
                    }
                } else {

                    html += '<div style="text-align: center;height: 100px;margin-top: 20px">' + res.msg + '</div>';
                }
                $(".show").html(html)
            }
        });
    });
</script>
